<?php
class App_Tpl_Form_Field_Checkbox extends App_Tpl_Form_Field{

	public function PreparePost($fieldPostData, $params)
	{
		$fieldPostData = (array) $fieldPostData;
		
		$values = (array)$params['values'];
		$resValue = array();
		while (list ($postKey, $postVal) = each($fieldPostData))
		{
			if (isset($values[$postVal])) $resValue[$postKey] = $postVal;
		}
		
		return $resValue;
	}
	
	public function PrepareOut($fieldData, $params)
	{
		return (array)$fieldData;
	}
	
    protected function RenderField()
    {
    	return $this->render('form/field/_checkbox.phtml');
    }

}